// Поиск по оператору R максимальных допустимых FL, 
// в столбцах матриц которых содержатся связные состояния
// результат в logs/max_heights_<topology_file_name>
//=========================================================
#include <stdio.h>
#include "air.hpp"
//=========================================================
int main(int argc, char **argv){
  char *topology;
  if(argc<2){
    printf("Error: try ./heights <topology_file>\n");
    return 1;
  }
  topology = argv[1];
  air *air_space;
  FILE *fd;
  air_space = new air(topology);
  if(air_space->get_name() != NULL){
    char logpath[100];
    snprintf(logpath,sizeof(logpath),"logs/mine-fields_%s",topology);
    fd = fopen(logpath,"w+");
    if(fd == NULL){
      perror("Error: opening log file source");
    }else{
      air_space->set_min_r(5);

      air_space->print(fd);
      air_space->print(stdout);

      air_space->interpolation();
      printf("after interpolation\n");
      air_space->count_quant_states();
      printf("after count\n");
      printf("MAX кол-во квантовых состояний = %d\n",air_space->get_max_quant_state());
      
      air_space->set_linked_qstate(fd);
      air_space->generate_mine_field();

      air_space->get_max_heights();

      air_space->print_mine_field(fd);
      air_space->print_mine_field(stdout);
      
      fclose(fd);
    }
  }
 return 0; 
}  
